/**
 * 
 */ 
package com.tueye.dao.impl.usermanager; 

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Qualifier;
import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Component;

import com.tueye.base.util.IBaseHbnDao;
import com.tueye.base.util.Page;
import com.tueye.dao.usermanager.IUserTopicManagerDao;
import com.tueye.entity.user.UserCollectionInfo;

/** 
 * @author 作者 yuyue E-mail: z_yuguangyue@126.com
 * @version 创建时间：Mar 26, 2009 7:30:07 PM 
 * Title:
 * Description:
 * ChangeDate:Mar 26, 2009 7:30:07 PM 
 * @ see 
 */
 
@Scope("prototype")
@Component("userTopicMangerDao")
public class UserTopicManagerDaoImpl implements IUserTopicManagerDao {

	
	@Autowired
	@Qualifier("baseHbnDao")
	private IBaseHbnDao  baseHbnDao;

	@Override
	public Page getAllCollectTopicByUserId(String userid) {
		// TODO Auto-generated method stub
		return null;
	}

	@Override
	public Page getAllTopicByUserId(String hql, int currentPage, int pageSize) {
		// TODO Auto-generated method stub
		return baseHbnDao.pagedQueryByHQL(hql, currentPage, pageSize, null);
	}

	@Override
	public List getOneTopicByAll(String topicid, String userId) {
		// TODO Auto-generated method stub
		String hql = "select t.topics from UserCollectionInfo t where t.userTopicType = 2 and t.user.id='"+userId +"' and t.topics.id='"+topicid +"'";
		return (List) baseHbnDao.queryList(hql);
	}

	@Override
	public void saveShouCang(UserCollectionInfo ui) {
		// TODO Auto-generated method stub
		baseHbnDao.saveOrUpdate(ui);
	}

	@Override
	public void delcollect(String userId, String topicid) {
		// TODO Auto-generated method stub
		String hql = "from UserCollectionInfo t where t.userTopicType = 2 and t.user.id='"+userId +"' and t.topics.id='"+topicid +"'";
		List list =baseHbnDao.queryList(hql);
		UserCollectionInfo ui = (UserCollectionInfo) list.get(0);
		baseHbnDao.delete(ui);
	}
	
	 
	

}
 